/**
 * Copyright (C) 2018-2020
 * All rights reserved, Designed By www.yixinzu.com

 */
package com.ruoyi.common.utils;

import com.qiniu.storage.Region;

/**
 * 七牛云存储工具类
 * @author pipi
 * @date 2018-12-31
 */
public class QiNiuUtil {

    private static final String HUAD_ZHEJIANG = "华东-浙江";

    private static final String HUAD_ZHEJIANG2 = "华东-浙江2";

    private static final String HUAB_HEBEI = "华北-河北";

    private static final String HUAN_GUANGDONG = "华南-广东";

    private static final String BEIM_LUOSHANJI = "北美-洛杉矶";

    private static final String YT_XINJIAPO = "亚太-新加坡";

    /**
     * 得到机房的对应关系
     * @param zone 机房名称
     * @return Region
     */
    public static Region getRegion(String zone){

        if(HUAD_ZHEJIANG.equals(zone)){
            return Region.huadong();
        } else if(HUAB_HEBEI.equals(zone)){
            return Region.huabei();
        }
        else if(HUAD_ZHEJIANG2.equals(zone)){
            return Region.regionCnEast2();
        }
        else if(HUAN_GUANGDONG.equals(zone)){
            return Region.huanan();
        } else if (BEIM_LUOSHANJI.equals(zone)){
            return Region.beimei();
        }else if (YT_XINJIAPO.equals(zone)){
            return Region.regionAs0();
        }
        else {//否则就是 亚太-首尔
            return Region.autoRegion();
        }
    }

//    /**
//     * 默认不指定key的情况下，以文件内容的hash值作为文件名
//     * @param file 文件名
//     * @return String
//     */
//    public static String getKey(String file){
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
//        Date date = new Date();
//        return FileUtil.getFileNameNoEx(file) + "-" +
//                sdf.format(date) +
//                "." +
//                FileUtil.getExtensionName(file);
//    }
}
